package ihm;

import java.awt.EventQueue;

import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLayeredPane;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.JTable;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.table.DefaultTableModel;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class FenetrePrincipale {

	private JFrame frmTempofixe;
	private JTable tblCollaborateurs;
	private JTable tblContrat;
	private JTable tblTaches;
	private JTabbedPane tbpTabs;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					FenetrePrincipale window = new FenetrePrincipale();
					window.frmTempofixe.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the application.
	 */
	public FenetrePrincipale() {
		initialize();
	}
	
	/**
	 * Initialize the contents of the frame.
	 */
	private void initialize() {
		frmTempofixe = new JFrame();
		frmTempofixe.setTitle("TempoFixe");
		frmTempofixe.setBounds(100, 100, 727, 408);
		frmTempofixe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		tbpTabs = new JTabbedPane(JTabbedPane.TOP);
		
		JLayeredPane lydpaneBoutons = new JLayeredPane();
		GroupLayout groupLayout = new GroupLayout(frmTempofixe.getContentPane());
		groupLayout.setHorizontalGroup(
			groupLayout.createParallelGroup(Alignment.TRAILING)
				.addGroup(Alignment.LEADING, groupLayout.createSequentialGroup()
					.addContainerGap()
					.addGroup(groupLayout.createParallelGroup(Alignment.TRAILING, false)
						.addComponent(tbpTabs, Alignment.LEADING)
						.addComponent(lydpaneBoutons, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 686, Short.MAX_VALUE))
					.addContainerGap(15, Short.MAX_VALUE))
		);
		groupLayout.setVerticalGroup(
			groupLayout.createParallelGroup(Alignment.LEADING)
				.addGroup(groupLayout.createSequentialGroup()
					.addComponent(tbpTabs, GroupLayout.PREFERRED_SIZE, 316, GroupLayout.PREFERRED_SIZE)
					.addPreferredGap(ComponentPlacement.UNRELATED)
					.addComponent(lydpaneBoutons, GroupLayout.PREFERRED_SIZE, 38, GroupLayout.PREFERRED_SIZE)
					.addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
		);
		
		JButton btnAjouter = new JButton("Ajouter");
		btnAjouter.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				switch (tbpTabs.getSelectedIndex()) {
				case 0 ://collaborateurs
					break;
				case 1 ://contrats
					break;
				case 2 ://tâches
					FenetreAjouterTache window = new FenetreAjouterTache();
					window.getFrmAjouterUneTche().setVisible(true);
					break;
				}
			}
		});
		btnAjouter.setBounds(0, 0, 202, 34);
		lydpaneBoutons.add(btnAjouter);
		
		JButton btnModifier = new JButton("Modifier");
		btnModifier.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				switch (tbpTabs.getSelectedIndex()) {
				case 0 ://collaborateurs
					break;
				case 1 ://contrats
					break;
				case 2 ://tâches
					break;
				}
			}
		});
		btnModifier.setBounds(201, 0, 279, 34);
		lydpaneBoutons.add(btnModifier);
		
		JButton btnSupprimer = new JButton("Supprimer");
		btnSupprimer.setBounds(479, 0, 207, 34);
		lydpaneBoutons.add(btnSupprimer);
		
		JScrollPane tabCollaborateurs = new JScrollPane();
		tbpTabs.addTab("Collaborateurs", null, tabCollaborateurs, null);
		
		tblCollaborateurs = new JTable();
		tblCollaborateurs.setModel(new DefaultTableModel(
			new Object[][] {
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
			},
			new String[] {
				"Matricule", "Nom", "Prenom"
			}
		));
		tabCollaborateurs.setViewportView(tblCollaborateurs);
		
		JScrollPane tabContrats = new JScrollPane();
		tbpTabs.addTab("Contrats", null, tabContrats, null);
		
		tblContrat = new JTable();
		tblContrat.setModel(new DefaultTableModel(
			new Object[][] {
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
				{null, null, null},
			},
			new String[] {
				"R\u00E9ference", "Objet", "Nom Client"
			}
		));
		tabContrats.setViewportView(tblContrat);
		
		JScrollPane tabTaches = new JScrollPane();
		tbpTabs.addTab("Tâches", null, tabTaches, null);
		
		tblTaches = new JTable();
		tblTaches.setModel(new DefaultTableModel(
			new Object[][] {
				{null, null, null, null, null},
				{null, null, null, null, null},
				{null, null, null, null, null},
				{null, null, null, null, null},
				{null, null, null, null, null},
				{null, null, null, null, null},
				{null, null, null, null, null},
				{null, null, null, null, null},
			},
			new String[] {
				"Num\u00E9ro", "Contrat", "Collaborateurs", "Libell\u00E9", "Charges"
			}
		));
		tabTaches.setViewportView(tblTaches);
		frmTempofixe.getContentPane().setLayout(groupLayout);
	}
}
